#!/usr/bin/env python

# This module consists of a series of classes.  Each class takes the
# intermediate lexicon for each accent.  Then each class populates four
# feature dictionaries:
#   1. part-of-speech
#   2. pronunciation
#   3. orthography
#   4. word frequency


from __future__ import with_statement

from config import PATH_TO_INTER_GAM


# Class for General American:
class _GAMinter(dict):
    """Four feature dicts for GAM"""

    dict_type = None

    def __init__(self, path_gam_inter=PATH_TO_INTER_GAM):
        """Instantiate and populate this current dict."""

        super(dict, self).__init__()

        assert self.dict_type in ('pos', 'pron', 'ortho', 'freq',)

        with open(path_gam_inter) as f:
            for line in f.readlines():
                word, pron_num, pos, pron, ortho, freq = line.split(':')
                value = locals()[self.dict_type]
                try:
                    self[word].append(value)
                except KeyError:
                    self[word] = [value]


class GamPOS(_GAMinter):
    dict_type = 'pos'
    
class GamPron(_GAMinter):
    dict_type = 'pron'

class GamOrtho(_GAMinter):
    dict_type = 'ortho'

class GamFreq(_GAMinter):
    dict_type = 'freq'
